Socket
Socket
Sign inDemoInstall

@peculiar/asn1-schema

Package Overview
Dependencies
Maintainers
6
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peculiar/asn1-schema

Decorators for ASN.1 schemas building


Version published
Maintainers
6
Created

What is @peculiar/asn1-schema?

@peculiar/asn1-schema is a JavaScript library for working with ASN.1 (Abstract Syntax Notation One) schemas. It provides tools for defining, encoding, and decoding ASN.1 data structures, which are commonly used in cryptographic protocols and data interchange formats.

What are @peculiar/asn1-schema's main functionalities?

Defining ASN.1 Schemas

This feature allows you to define ASN.1 schemas using decorators. The code sample demonstrates how to define a simple ASN.1 schema with an integer and a UTF-8 string.

const { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes } = require('@peculiar/asn1-schema');

@AsnType({ type: AsnTypeTypes.Sequence })
class MySchema {
  @AsnProp({ type: AsnPropTypes.Integer })
  public id = 0;

  @AsnProp({ type: AsnPropTypes.Utf8String })
  public name = '';
}

const schema = new MySchema();
schema.id = 1;
schema.name = 'Example';

Encoding ASN.1 Data

This feature allows you to encode data according to the defined ASN.1 schema. The code sample shows how to serialize an instance of the schema into an ASN.1 encoded format.

const { AsnConvert } = require('@peculiar/asn1-schema');

const schema = new MySchema();
schema.id = 1;
schema.name = 'Example';

const encoded = AsnConvert.serialize(schema);
console.log(encoded);

Decoding ASN.1 Data

This feature allows you to decode ASN.1 encoded data back into the defined schema. The code sample demonstrates how to parse an ASN.1 encoded byte array into an instance of the schema.

const { AsnConvert } = require('@peculiar/asn1-schema');

const encoded = new Uint8Array([48, 10, 2, 1, 1, 12, 5, 69, 120, 97, 109, 112, 108, 101]);
const decoded = AsnConvert.parse(encoded, MySchema);
console.log(decoded);

Other packages similar to @peculiar/asn1-schema

Keywords

FAQs

Package last updated on 01 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc